package lab03.test01.test11;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * Created by lenovo on 2017/12/13.
 */
public class Test {
    public static void main(String[] args) {
            //加载驱动
            Connection connection = null;
            Statement statement = null;
            //表名字：t_users
            String sql = "insert into t_users(id,username,password,register_datetime) values(1,'xie','123456',11111)";
            String sql1 = "insert into t_users(id,username,password,register_datetime) values(2,'zhao','123456',22222)";
            try {
                Class.forName("com.mysql.cj.jdbc.Driver");
                connection = DriverManager.getConnection(
                        "jdbc:mysql://localhost:3306/java_2017?serverTimezone=UTC",
                        "root",
                        "123456"
                );
                statement = connection.createStatement();
                statement.execute(sql);
                statement.execute(sql1);
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (SQLException e) {
                e.printStackTrace();
            } finally {
                try {
                    statement.close();
                    connection.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
        }
    }

